package com.cgbl.service.ui

import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Route
import com.cgbl.service.BR
import com.cgbl.service.R
import com.cgbl.service.databinding.AppActivityReleaseProjectBinding
import com.cgbl.service.pop.ProjectFilterPop
import com.cgbl.service.vm.ReleaseProjectViewModel
import com.lxj.xpopup.XPopup
import com.robot.base.base.activity.GLBaseActivity
import com.robot.base.configs.AppConstants

@Route(path = AppConstants.Router.Project.A_RELEASE_PROJECT)
class ReleaseProjectActivity : GLBaseActivity<AppActivityReleaseProjectBinding, ReleaseProjectViewModel>() {

    override fun initVariableId(): Int = BR.viewModel

    override fun initContentView(savedInstanceState: Bundle?): Int = R.layout.app_activity_release_project

    override fun initComponents() {
        addSingleTitleBar("修改项目")
    }

    override fun initViewObservable() {
        super.initViewObservable()
        viewModel.uc.showTypeDialog.observe(this) {
            val filterPop =
                ProjectFilterPop(this, viewModel.typeText.get() ?: "", viewModel.list)
            XPopup.Builder(this)
                .atView(binding.tvContent1)
                .asCustom(filterPop)
                .show()

            filterPop.setConfirmClickListener {
                filterPop.dismiss()
                viewModel.typeText.set(it)
            }
        }
    }
}